package com.snow.campuslink.user.controller;


import com.snow.campuslink.project.result.Result;
import com.snow.campuslink.user.entity.UserFriendship;
import com.snow.campuslink.user.service.IUserFriendshipService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Gaosl
 * @since 2021-03-02
 */
@RestController
@RequestMapping("/user/user-friendship")
public class UserFriendshipController {
    @Resource
    IUserFriendshipService userFriendshipService;

    @ApiOperation(value = "")
    @PostMapping("saveFriendship")
    public Result saveFriendship(@RequestBody UserFriendship userFriendship){
        userFriendshipService.save(userFriendship);
        return Result.success();
    }

    @ApiOperation(value = "")
    @GetMapping("getFriendship")
    public Result getFriendship(@RequestBody UserFriendship userFriendship){
        List<UserFriendship> list= userFriendshipService.getFocus(userFriendship);
        return Result.success().data(list);
    }

    @ApiOperation("")
    @DeleteMapping("deleteFocus/{friendshipId}")
    public Result removeById (@PathVariable("friendshipId") Long friendshipId){
        userFriendshipService.removeById(friendshipId);
        return Result.success();
    }


}

